#!/bin/bash

CLIENT_PROGRAM="pro_client"
CURRENT_PATH=$(pwd)
SRC_PATH="$CURRENT_PATH/src/"
INC_PATH="$CURRENT_PATH/include/"
SQL_PATH="$CURRENT_PATH/../sqlite/include/"
SOURCE_FILE="main.c"
LIBSQL="-L../sqlite/lib -lsqlite3"
CLISQL="-L $CURRENT_PATH/install/libs -lclient"

echo "正在编译并连接库生成可执行程序..."
gcc -g "$SOURCE_FILE" -I $SQL_PATH -I $INC_PATH $CLISQL $LIBSQL -lpthread -ldl -lm  -o "$CLIENT_PROGRAM"

# 检查编译是否成功
if [ $? -ne 0 ]; then
	echo "编译失败，请检查代码和库的配置。"
	exit 1
fi

echo "可执行程序 $CLIENT_PROGRAM 已成功生成。"
export LD_LIBRARY_PATH=`pwd`/../sqlite/lib/:$LD_LIBRARY_PATH

echo "执行程序"
./$CLIENT_PROGRAM -i  127.0.0.1 -p 6666 -s risp0001 -t 10 -P tlv

